<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <link rel="stylesheet"type="text/css"href="css/menu.css">
        <title>Nhan</title>
    </head>
    
    <body id="body">
        <div id="header">       
        </div>
        <div id="menu">
            <ul id="s">
                <li><a href="#">Home</a>
                </li>
                <li><a href="#">About Us</a>
                </li>
                <li><a href="#">Forums</a>
                </li>
                <li><a href="#">Contact</a>
                </li>
            </ul>
        </div>
        <div id="page_body">       
            <?php
            require_once './model/db.php';
            $keywords = new connect_db();
            $danhsach = $keywords->select1();
            ?>
    <form method="post"      enctype="multipart/form-data">
    <label for="file">Filename:</label>
    <input type="file" name="file" id="file"><br>
    <input type="submit" name="submit" value="Submit">
</form>


<?php
if (isset($_POST['submit'])) {
    $allowedExts = array("gif", "jpeg", "jpg", "png");
    $temp = explode(".", $_FILES["file"]["name"]);
    $extension = end($temp);
    if ((($_FILES["file"]["type"] == "image/gif")
            || ($_FILES["file"]["type"] == "image/jpeg")
            || ($_FILES["file"]["type"] == "image/jpg")
            || ($_FILES["file"]["type"] == "image/pjpeg")
            || ($_FILES["file"]["type"] == "image/x-png")
            || ($_FILES["file"]["type"] == "image/png"))
            && ($_FILES["file"]["size"] < 100000)
            && in_array($extension, $allowedExts)) {
        if ($_FILES["file"]["error"] > 0) {
            echo "Return Code: " . $_FILES["file"]["error"] . "<br>";
        } else {
            echo "Upload: " . $_FILES["file"]["name"] . "<br>";
            echo "Type: " . $_FILES["file"]["type"] . "<br>";
            echo "Size: " . ($_FILES["file"]["size"] / 1024) . " kB<br>";
            echo "Temp file: " . $_FILES["file"]["tmp_name"] . "<br>";

            if (file_exists("./data/picture/" . $_FILES["file"]["name"])) {
                echo $_FILES["file"]["name"] . " already exists. ";
            } else {
                move_uploaded_file($_FILES["file"]["tmp_name"], "./data/picture/" . $_FILES["file"]["name"]);
                echo "Stored in: " . "F:\images/" . $_FILES["file"]["name"];
            }
            $url="./data/picture/" . $_FILES["file"]["name"];
            echo "<img src='$url' width='400px' />";
        }
    } else {
        echo "Invalid file";
    }
}
?>
            <br>
            
            <br><br><table>
                <?php
                $baitren_mottrang = 10;
                if (!isset($_GET['page'])) {
                    $page = 0;
                } else {
                    $page = (int) $_GET['page'];
                }
                $sodu_lieu = mysql_num_rows(mysql_query("SELECT * FROM works ")) or die(mysql_error());
                $sotrang = 10;
                $huuha = $page * $baitren_mottrang;
                $result = mysql_query("SELECT * FROM works LIMIT {$huuha},{$baitren_mottrang} ") or die(mysql_error());
                $max = $sotrang;
               
                while ($info = mysql_fetch_array($result)) {
                    echo $info['id'] . "  ";
                    echo $info['name'] . "  ";
                    echo "<br>";
                }
                echo "<a href='index.php?page=0'> First </a>";
                for ($page = 0; $page <= $sotrang; $page++) {
                    echo "<a href='index.php?page={$page}'> {$page} </a>";
                }
                echo "<a href='index.php?page={$max}'> Last </a>";
                ?>
            </table>
        </div>
        <div id="conten">       
        </div>
        <div id="sidebar">       
        </div>
        <div id="footer">       
        </div>
    </body>
</html>

